#ifndef PARAFLUIDSIMULATION_H
#define PARAFLUIDSIMULATION_H

#include "parafluidatom.h"
#include "parafluidcolor.h"
#include "parafluidsph.h"
#include "parafluidsubstance.h"
#include "parafluidvector.h"

#include <QTimer>
#include <QVector>

namespace ParaFluid
{
	
	/**
	* Simulation
	*/
	class Simulation
		: public QObject
	{
		
		Q_OBJECT
		
	public:
		
		~Simulation();
		
		Simulation(unsigned int buckets = 5000);
		
		const SPH & sph() const;
		
		const QVector<Substance> & substances() const;
		
		bool isRunning() const;
		
	public slots:
		
		void start();
		
		void pause();
		
		void stop();
		
		void step();
		
		void resetSimulation();
		
		void resetParameters();
		
		void insertAtoms(int substance, int qty);
		
		void setSmoothingDistance(float value);
		
		void setTimeStep(float value);
		
		void setGravity(const Vector & value);
		
		void setConstraints(const Box & value);
		
		void addSubstance(const Substance & value);
		
		void setSubstanceMass(int substance, float value);
		
		void setSubstanceColor(int substance, const Color & value);
		
		void setSubstancePressureFactor(int substance, float value);
		
		void setSubstanceRestDensity(int substance, float value);
		
		void setSubstanceViscosityFactor(int substance, float value);
		
	protected:
		
	private:
		
		Substance & substance(int substance);
		
		QTimer _stepper;
		
		SPH _sph;
		
		QVector<Substance> _substances;
		
	signals:
		
		void stepped();
		
		void changedSmoothingDistance(float value);
		
		void changedTimeStep(float value);
		
		void changedGravity(const Vector & value);
		
		void changedConstraints(const Box & value);
		
		void changedSubstanceMass(int substance, float value);
		
		void changedSubstanceColor(int substance, const Color & value);
		
		void changedSubstancePressureFactor(int substance, float value);
		
		void changedSubstanceRestDensity(int substance, float value);
		
		void changedSubstanceViscosityFactor(int substance, float value);
		
	};
	
}

#endif

